package com.wl.listener;

import javax.servlet.ServletContextAttributeEvent;
import javax.servlet.ServletContextAttributeListener;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;


@WebListener
public class BListener implements HttpSessionListener,
                                  HttpSessionAttributeListener,
                                  ServletContextListener,
                                  ServletContextAttributeListener {
    @Override
    public void sessionCreated(HttpSessionEvent httpSessionEvent) {
        System.out.println("session被创建");
    }

    @Override
    public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {
        System.out.println("session被销毁");
    }

    @Override
    public void attributeAdded(HttpSessionBindingEvent e) {
        System.out.println("session添加属性：" + e.getName() +",属性值:" + e.getValue());
    }

    @Override
    public void attributeRemoved(HttpSessionBindingEvent e) {
        System.out.println("session移除属性：" + e.getName() +",属性值:" + e.getValue());
    }

    @Override
    public void attributeReplaced(HttpSessionBindingEvent e) {
        System.out.println("session替换属性：" + e.getName() +",属性值:" + e.getValue());
    }

    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
        System.out.println("应用程序上下文被初始化");
    }

    @Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) {
        System.out.println("应用程序上下文被销毁");
    }

    @Override
    public void attributeAdded(ServletContextAttributeEvent e) {
        System.out.println("app添加属性：" + e.getName() +",属性值:" + e.getValue());
    }

    @Override
    public void attributeRemoved(ServletContextAttributeEvent e) {
        System.out.println("app移除属性：" + e.getName() +",属性值:" + e.getValue());
    }

    @Override
    public void attributeReplaced(ServletContextAttributeEvent e) {
        System.out.println("app替换属性：" + e.getName() +",属性值:" + e.getValue());
    }
}
